﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web;
using VideoNetApplication.Common.Service;
using VideoNetApplication.Common.Helper;
using  System.Configuration;

namespace VideoNetApplication.Common
{
  public  class BasePage:System.Web.UI.Page
  {
      
      private int _schoolId;



      //protected override void OnLoad(EventArgs e)
      //{
      //    if (MembershipService.GetUser() == null)
      //    {

      //        Response.Redirect("~/Default.aspx");
      //    }


      //    base.OnLoad(e);
      //}
      private string _baseurl = ConfigurationManager.AppSettings["BaseUrl"];
      public  string  Baseurl
      {
          get { return _baseurl; }
          set { _baseurl = value; }
      }
      private string _pictureServerName = ConfigurationManager.AppSettings["PictureServerName"];
      public  string    PictureServerName
      {
          get { return _pictureServerName; }
          set { _pictureServerName = value; }
      }

      public int SchoolId
      {
          get
          {
              if (ConfigurationManager.AppSettings["IsConfig"] == "1")
              {

                  if (HttpContext.Current.Request["SchoolId"] != null && StringUtils.IsNumeric(HttpContext.Current.Request["SchoolId"]))
                  {
                      _schoolId = Convert.ToInt32(HttpContext.Current.Request["SchoolId"]);
                  }
              }
              else {

                  _schoolId = Convert.ToInt32( ConfigurationManager.AppSettings["SchoolID"]);
              }
              return _schoolId;
          }
          set { _schoolId = value; }
      }


      protected override void OnInit(EventArgs e)
      {
          //SQL防注入攻击
          if (Request.QueryString.Count > 0)
          {
              int loop1;
              NameValueCollection coll = Request.QueryString;
              String[] arr1 = coll.AllKeys;
              for (loop1 = 0; loop1 < arr1.Length; loop1++)
              {
                  String[] arr2 = coll.GetValues(arr1[loop1]);
                  int loop2;
                  for (loop2 = 0; loop2 < arr2.Length; loop2++)
                  {
                      string SQL_Repdata = ";--|exec|insert|select|delete|update|count|chr|mid|master|truncate|char|declare|create|drop";
                      String[] arr3 = SQL_Repdata.Split(char.Parse("|"));
                      int loop3;
                      for (loop3 = 0; loop3 < arr3.Length; loop3++)
                      {
                          if (arr2[loop2].ToLower().Trim().IndexOf(arr3[loop3]) > -1)
                          {
                              Response.Write("系统警告：你的行为被系统认定为[非法用户行为]！如有任何疑问,请和网站管理员联系。");
                              Response.End();
                          }
                      }
                  }
              }
          }
          base.OnInit(e);
      }
    }
}
